<%@ page import="com.ld.manageBook.service.UserService" %>
<%@ page import="com.ld.manageBook.service.impl.UserServiceImpl" %>
<%@ page import="com.ld.manageBook.bean.User" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 刘邓
  Date: 2023-06-01
  Time: 15:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户管理</title>
</head>
<body>
<%!
    private UserService userService= new UserServiceImpl();
%>
<%
    List<User> users = userService.getAllUsers();
    out.println("<a href='/home/addUser.jsp'>添加用户</a><br>");
    out.println("<table style='width:60%;height:400px;margin:0 auto; border:1px solid #ccc;cellspacing:0; cellpadding:0'>" +
            "<tr>" +
            "<th>id</th>" +
            "<th>用户名</th>" +
            "<th>密码</th>" +
            "<th>权限</th>" +
            "<th>修改</th>" +
            "<th>删除</th>" +
            "</tr>");
    for (User user : users) {
        String changeDOM = "<td><a href=" + "'/home/changeUser.jsp?id=" + user.getId() + "'>修改" + "</a></td>";
        String deleteDOM = "<td><a href=" + "'/home/deleteUser.jsp?id=" + user.getId() + "'>删除" + "</a></td>";
        out.println("<tr>");
        out.println("<td style='text-align:center'>" + user.getId() + "</td>");
        out.println("<td style='text-align:center'>" + user.getUsername() + "</td>");
        out.println("<td style='text-align:center'>" + user.getPassword() + "</td>");
        out.println("<td style='text-align:center'>" + user.getStatus() + "</td>");
        out.println(changeDOM);
		out.println(deleteDOM);
        out.println("</tr>");
    }
	out.println("</table>");
%>
</body>
</html>
